package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.UserTypeEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 任务开始请求参数类
 *
 * @author lijian
 * @version 2014年10月20日 - 下午2:18:58
 */
public class TaskStartRequest extends Request {

	private Integer totalFlowId;
	
	private Integer userId;
	
	private Integer levelId;
	
	public TaskStartRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.totalFlowId = requestInfo.getIntParameter(ApiUrlParamEnum.totalFlowId.getParamName(), 0);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.levelId = requestInfo.getIntParameter(ApiUrlParamEnum.level.getParamName(), UserTypeEnum.ALL.getType());
		
		if (totalFlowId < 1) {
			throw new RequestIllegalException("error totalFlowId: " + totalFlowId);
		}
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
	}

	public Integer getTotalFlowId() {
		return totalFlowId;
	}

	public void setTotalFlowId(Integer totalFlowId) {
		this.totalFlowId = totalFlowId;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getLevelId() {
		return levelId;
	}

	public void setLevelId(Integer levelId) {
		this.levelId = levelId;
	}

}
